﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MensUnoShop.Models.ViewModels.MarketViewModel>" %>
<%@ Import Namespace="MensUnoShop.Helpers" %>
<%@ Import Namespace="MensUnoShop.Models" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	men'suno SHOP
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="CONTENT2">
<div class="CONTENT_LEFT">
<ul>
            <%Html.RenderPartial("/Views/Shared/SearchBox.ascx"); %>
            <%Html.RenderPartial("/Views/Shared/ProductTitle.ascx",Model.LEFTTAG); %>
            <%Html.RenderPartial("/Views/Shared/HotSearch.ascx",Model.HOTKEYLIST); %>
            <%Html.RenderPartial("/Views/Shared/News.ascx",Model.NEWS); %>
        </ul></div>
<div class="CONTENT_RIGHT">
    <p class="FAST_LINK"><%=Html.GetNavLinkString(Model.NAVLIST)%></p>
    <img src="<%:Model.MARKET.IMG %>" class="PRODUCT3_IMG" />
    <ul class="PRODUCT3_CONTENT">
    <li class="PRODUCT3_STYLE"><%:Model.MARKET.TITLE %></li>
    <li></li>
    <li class="PRODUCT_COMES_BT"> <%=Html.GetAmountOnlyString(Model.PRODUCT.SPEC)%></li>
    <li>
        <input type="radio" name="speccode" value="0" checked="checked" />
        新訂戶：<span class="PRODUCT3_PRICE">NTD <%:((MagazineMarket)Model.MARKET).NEWPRICE %></span></li>
    <li>
        <input type="radio" name="speccode" value="1" />
        舊訂戶：<span class="PRODUCT3_PRICE">NTD <%:((MagazineMarket)Model.MARKET).OLDPRICE %></span></li>
    <li>
        <div class="PUTIN_SHOPPING_CART">
        <ul class="PRODUCT3_SHARE">
            <li class="PRODUCT3_SHARE_FACEBOOK"><a href="#">facebook</a></li>
            <li class="PRODUCT3_SHARE_TWITTER"><a href="#">twitter</a></li>
            <li class="PRODUCT3_SHARE_PLURK"><a href="#">plurk</a></li>
            <li class="PRODUCT3_SHARE_SINA"><a href="#">sina</a></li>
        </ul>
        </div>
        <br class="CLEAR" />
    </li>
    <li><a href="#" class="intoCart"><img src="/Content/page_img/cart_bt_magazine.gif" /></a></li>
  </ul>
   <br class="CLEAR" />
        <ul id="pdintro">
             <li class="PRODUCT3_CONTENT_WORD"><%=((MensUnoShop.Models.MagazineMarket)Model.MARKET).INTRODUCTION %></li>
            <%foreach (var mk in ((MensUnoShop.Models.MagazineMarket)Model.MARKET).MARKETIMG)
              { %>
            <li class="PRODUCT3_CONTENT_IMGAE">
                <p>▼<%:mk.TITLE %></p>
                <div><img src="<%:mk.PATH %>" width="500"/></div>
            </li>
            <%} %>
            
        </ul>
    <br class="CLEAR" />
    <img src="/Content/page_img/content2_bottom.gif" />
</div>
<br class="CLEAR" />
</div>
<script type="text/javascript">
$(document).ready(function () { $('.intoCart').click(goShopping); shareArticle();});
function goShopping() {
    <%if(Model.MEMBER==null){ %>
        alert('請先登入會員!!');
    <%}else if(Model.PRODUCT.SPEC.Sum(s=>s.STOCK)==0){ %>
            alert('賣場暫無庫存!!');
    <%}else{ %>
       if($("#specamt").val() > "0"){
           var jsonstring = {  "Mid": '<%:Model.MARKET.MKGUID %>',
                               "ProductId": '<%:Model.PRODUCT.PDGUID %>',
                               "SpecId": $("input[name=speccode]:checked").val(),
                               "AmountId": $("#specamt").val(),
                               "Mktype":2
                             };
            $.ajax({
                type: "POST",
                traditional: true,
                url: "/api/jtc",
                data: jsonstring,
                dataType: "json",
                success: function (data) {
                    if(data.code=="200"){
                        location.href='/order/fs';
                    }
                    else
                        alert(data.response);
                } 
            });
        }
        else
            alert('請選擇數量');
        <%} %>
    }

    $(window).load(function(){
	    $('#pdintro img').each(function(i){
			$(this).removeAttr('width');
			$(this).removeAttr('height');
 
			//取得影像實際的長寬
			var imgW = $(this).width();
			var imgH = $(this).height();
 
			//計算縮放比例
			var w=500/imgW;
			var pre=1;
			if(w<1){
				pre=w;
			}else{
				pre=1;
			}
 
			if(pre!=1){
			    $(this).width(500);
			    $(this).height(imgH*pre);
                }
		});
    });
</script>

</asp:Content>
